import request from '@/utils/request'
import type { ApiResponse } from '@/types'

export interface DashboardData {
  user: {
    id: number
    username: string
    school: string
    grade: string
    avatar: string
    stars: number
    total_correct: number
    total_wrong: number
    continuous_days: number
    accuracy: number
  }
  stats: {
    words_learned: number
    avg_mastery: number
    total_correct: number
    total_wrong: number
    achievements_count: number
  }
  pet: any
  daily_tasks: Array<{
    id: number
    task_type: string
    target_count: number
    current_count: number
    completed: boolean
    stars_reward: number
    progress: number
  }>
}

export const dashboardApi = {
  // 获取Dashboard数据
  getDashboardData(): Promise<ApiResponse<DashboardData>> {
    return request.get('/dashboard')
  },
  
  // 更新任务进度
  updateTaskProgress(taskType: string): Promise<ApiResponse<any>> {
    return request.post('/dashboard/task/update', { task_type: taskType })
  }
}

